import website from 'src/const/website'
import { setStore, getStore, clearStore } from 'src/util/store'
import routes from 'src/router/routes'
const common = {
  state: {
    website: website,
    // menu: getStore('menu')|| [],
    menu: routes,
    access_token: getStore({name:'access_token'})|| '',
    signKey: getStore({name:'signKey'})|| ''
  },
  actions: {
    LogOutByLoginFirst ({ commit }) {
      // 删除所有的sessionStorage
      clearStore({type: 'session'})
    },
  },
  mutations: {
    SET_MENU:(state, menu)=>{
      state.menu = menu
      setStore({
        name: 'menu',
        content: state.menu,
        type: 'session'
      })
    },
    SET_ACCESS_TOKEN: (state, accessToken) => {
      state.access_token = accessToken
      setStore({
        name: 'access_token',
        content: state.access_token,
        type: 'session'
      })
    },
    SET_SIGNKEY: (state, signKey) => {
      state.signKey = signKey
      setStore({
        name: 'signKey',
        content: state.signKey,
        type: 'session'
      })
    },
  }
}
export default common
